package com.zyg.educms.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zyg.commonutils.R;
import com.zyg.educms.entity.CrmBanner;
import com.zyg.educms.service.CrmBannerService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/educms/bannerfront")
public class BannerFrontController {
    @Autowired
    private CrmBannerService bannerService;
    @ApiOperation(value = "查询所有的banner")

    @GetMapping("getAllBanner")
    public R getAllBanner() {
        QueryWrapper<CrmBanner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id");
        wrapper.last("limit 2");
        List<CrmBanner> list = bannerService.selectAllBanner(wrapper);
        return R.ok().data("list", list);
    }
}
